package com.guanzi.server.mapper;

import com.guanzi.server.entity.Order;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.guanzi.server.entity.vo.StoreVO;
import com.guanzi.server.entity.vo.UserVO;
import org.apache.ibatis.annotations.Select;
import org.springframework.stereotype.Repository;

import java.util.List;

/**
 * <p>
 *  Mapper 接口
 * </p>
 *
 * @author guanzi
 * @since 2021-06-04
 */
@Repository
public interface OrderMapper extends BaseMapper<Order> {

    /**
     * 获取用户信息
     * @return
     */
    @Select("SELECT DISTINCT u.id AS userId, u.username AS userName FROM `e_order` AS o INNER JOIN `e_user` AS u ON o.e_user_id=u.id")
    List<UserVO> selectUser();

    /**
     * 获取商家信息
     * @return
     */
    @Select("SELECT DISTINCT s.id AS id, s.name AS name FROM `e_order` AS o INNER JOIN `e_store` AS s ON o.e_store_id=s.id")
    List<StoreVO> selectStore();
}
